package org.dromara.app.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.dromara.app.service.AHisOpinionService;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.validate.EditGroup;
import org.dromara.common.excel.utils.ExcelUtil;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.web.core.BaseController;
import org.dromara.bean.domain.bo.HisOpinionBo;
import org.dromara.bean.domain.vo.HisOpinionVo;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 意见反馈
 *
 * @author Lion Li
 * @date 2025-01-02
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/app/opinion")
public class AHisOpinionController extends BaseController {

    private final AHisOpinionService hisOpinionService;


    /**
     * 查询意见反馈列表
     */
    @GetMapping("/list")
    public TableDataInfo<HisOpinionVo> list(HisOpinionBo bo, PageQuery pageQuery) {
        return hisOpinionService.queryPageList(bo, pageQuery);
    }



    /**
     * 获取意见反馈详细信息
     *
     * @param id 主键
     */
    @GetMapping("/{id}")
    public R<HisOpinionVo> getInfo(@NotNull(message = "主键不能为空")
                                     @PathVariable Long id) {
        return R.ok(hisOpinionService.queryById(id));
    }



    /**
     * 新增意见反馈
     */
    @Log(title = "意见反馈", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(EditGroup.class) @RequestBody HisOpinionBo bo) {
        return toAjax(hisOpinionService.insertByBo(bo));
    }


}
